<?php
include_once("./core/config.php");
error_reporting(E_ALL);
set_time_limit(0);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
require_once  './core/Classes/PHPExcel.php';


$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8mb4")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}

$sql="select * from chi where type=3 order by uid ";
$query=$mysqli->query($sql);
$chi=array();
while ($list = $query->fetch_array()){
	$chi[]=array('uid'=>$list['uid']);
}

$er=array();
foreach ($chi as $key=>$value){
	$sql="select * from erwei where id='".$value['uid']."' limit 0,1 ";
	$query=$mysqli->query($sql);
	$row=$query->fetch_array();
	$er[]=$row['name'];

}

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '二维码');
$i=2;
foreach ($er as $v){
	$objPHPExcel->setActiveSheetIndex(0)
	->setCellValue('A'.$i, strtoupper($v))
	;
	$i++;
}

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

$date = date("Y-m-d", time()-86400);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header("Content-Type:application/vnd.ms-execl");
header('Content-Disposition:attachment;filename=er.xlsx');
header("Content-Transfer-Encoding:binary");

$objWriter->save('php://output');



